import { _IFormEl, _IExtra } from "@/src/components/common/form/interface";
import { ColProps, FormItemProps, TableColumnProps } from "ant-design-vue";
import { formatAmt } from "@/util/format.ts";
import { numberC } from "@/util/common";

const formItemProps = {
  labelWidth: "120px",
  colon: false,
};

// 保险信息表单
export const insureFormEls: Array<_IFormEl> = [
  { label: "购买日期", key: "insurancedate", col: { span: 8 }, element: "datepicker", formItemProps: formItemProps },
  { label: "保费", key: "insuramt", col: { span: 8 }, element: "money", formItemProps: formItemProps },
  { label: "保险公司", key: "fkmechanismid", col: { span: 8 }, element: "select", formItemProps: formItemProps },
  { label: "保险生效日期", key: "insureffectdate", col: { span: 8 }, element: "datepicker", formItemProps: formItemProps },
  { label: "保险到期日期", key: "insurduedate", col: { span: 8 }, element: "datepicker", formItemProps: formItemProps },
  { label: "是否报销", key: "isreimburse", col: { span: 8 }, element: "select", formItemProps: formItemProps },
  { label: "备注说明", key: "remark", col: { span: 8 }, element: "textarea", formItemProps: formItemProps },
];

// 保险记录
export const insureRecordCols: Array<TableColumnProps> = [
  { align: "center", title: "序号", width: 50, customRender: ({ index }) => (index += 1) },
  {
    title: "购买/购入日期",
    minWidth: 130,
    dataIndex: "insurancedate",
    align: "center",
    customRender: ({ text }) => (text || "").split(" ")[0],
  },
  {
    title: "生效日期",
    minWidth: 130,
    dataIndex: "insureffectdate",
    align: "center",
    customRender: ({ text }) => (text || "").split(" ")[0],
  },
  {
    title: "保险到期日期",
    minWidth: 130,
    dataIndex: "insurduedate",
    align: "center",
    customRender: ({ text }) => (text || "").split(" ")[0],
  },
  { title: "保费(元)", minWidth: 130, dataIndex: "insuramt", align: "right", customRender: ({ text }) => formatAmt(numberC(text)) },
  { title: "保险公司", minWidth: 130, dataIndex: "mechanismname", align: "center" },
];
